import time

def buble(m):
    ended = True
    while ended:
        ended = False
        for i in range(1, len(m)):
            if m[i] < m[i - 1]:
                m[i], m[i - 1] = m[i - 1], m[i]
                ended = True

with open('m1_sorted.txt') as f:
    m1 = list(map(int, f.readlines()))
    t1 = time.time()
    buble(m1)
    t2 = time.time()
    print(t2 - t1)
    print(m1)

with open('m2_reverse.txt') as f:
    m2 = list(map(int, f.readlines()))
    t3 = time.time()
    buble(m1)
    t4 = time.time()
    print(t4 - t3)
    print(m2)

with open('m1_sorted.txt') as f:
    m3 = list(map(int, f.readlines()))
    t5 = time.time()
    buble(m1)
    t6 = time.time()
    print(t6 - t5)
    print(m3)
